package com.mindframe.MapasGoogle;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class OverlayMapa extends Overlay{
	
	Double lat = 36.77*1E6;
	Double lon = -6.35*1E6;
	
	
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow){
		
		Projection projection = mapView.getProjection();
		
		GeoPoint geoPoint = new GeoPoint(lat.intValue(), lon.intValue());
		
		if(!shadow){
			Point centro = new Point();
			
			projection.toPixels(geoPoint, centro);
			
			Paint p = new Paint();
			p.setColor(Color.BLUE);
			
			Bitmap bm = BitmapFactory.decodeResource(mapView.getResources(), R.drawable.marcador_google_maps);
			
			canvas.drawBitmap(bm, centro.x -bm.getWidth(), centro.y-bm.getHeight(), p);
		}
		
	}
	
	@Override
	public boolean onTap(GeoPoint point, MapView mapView){
		
		Context contexto = mapView.getContext();
		String msg = "Lat: " + point.getLatitudeE6() + " Lon: " + point.getLongitudeE6();
		
		Toast toast = Toast.makeText(contexto, msg, Toast.LENGTH_SHORT);
		
		toast.show();
		
		return true;
	}
	

	

}
